cmake_minimum_required(VERSION 3.5 FATAL_ERROR)

project(test_exe_proc LANGUAGES NONE)

find_package(PythonInterp REQUIRED)

# this is set as variable to prepare for abstraction using loops or functions
set(module_name "cffi")
execute_process(
  COMMAND
      ${PYTHON_EXECUTABLE} "-c" "import ${module_name}; print(${module_name}.__version__)"
  OUTPUT_VARIABLE stdout
  ERROR_VARIABLE stderr
  OUTPUT_STRIP_TRAILING_WHITESPACE
  ERROR_STRIP_TRAILING_WHITESPACE
)

if(stderr MATCHES "ModuleNotFoundError")
    message(STATUS "Module ${module_name} not found")
else()
    message(STATUS "Found module ${module_name} v${stdout}")
endif()